import Vue from 'vue'
import Router from 'vue-router'

// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
*                                if not set alwaysShow, only more than one route under the children
*                                it will becomes nested mode, otherwise not show the root menu
* redirect: noredirect           if `redirect:noredirect` will no redirct in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
  }
**/
export const constantRouterMap = [
  { path: '/login', component: () => import('@/views/login/index'), hidden: true },
  { path: '/404', component: () => import('@/views/404'), hidden: true },

  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    name: 'Dashboard',
    hidden: false,
    children: [{
      path: 'dashboard',
      component: () => import('@/views/dashboard/index'),
      meta: { title: 'Dashboard', icon: 'desktop' }
    }]
  },
  // 用户管理路由
  {
    path: '/user',
    component: Layout,
    redirect: '/user/index',
    name: '用户管理',
    meta: { title: '用户管理', icon: 'user' },
    children: [
      {
        path: 'index',
        name: 'user_index',
        component: () => import('@/views/user/index'),
        meta: { title: '用户列表', icon: 'user_list', roles: [99, 1] }
      },
      {
        path: 'user_theme',
        name: 'user_theme',
        hidden: true,
        component: () => import('@/views/user/user_theme'),
        meta: { title: '用户主题列表', icon: 'user_list', roles: [99, 1] }
      },
      {
        path: 'admin',
        name: 'admin_index',
        component: () => import('@/views/admin/index'),
        meta: { title: '管理员列表', icon: 'admin', roles: [99] }
      }
    ]
  },
  // 订单管理
  {
    path: '/order',
    component: Layout,
    redirect: '/order/index/',
    name: '订单管理',
    meta: { title: '订单管理', icon: 'order' },
    children: [
      {
        path: 'index',
        name: '订单列表',
        component: () => import('@/views/order/index'),
        meta: { title: '订单列表', icon: 'order' }
      }
    ]
  },
  // 邀请管理路由
  {
    path: '/invite',
    component: Layout,
    redirect: '/invite/index/',
    name: '邀请管理',
    meta: { title: '邀请管理', icon: 'share' },
    children: [
      {
        path: 'index',
        name: '邀请列表',
        component: () => import('@/views/invite/index'),
        meta: { title: '邀请列表', icon: 'share' }
      },
      {
        path: 'members',
        name: '成员管理',
        hidden: true,
        component: () => import('@/views/invite/members'),
        meta: { title: '成员管理', icon: 'members' }
      }
    ]
  },
  // 渠道
  {
    path: '/channel',
    component: Layout,
    redirect: '/channel/index/',
    name: '支付项管理',
    meta: { title: '支付项管理', icon: 'channel' },
    children: [
      {
        path: 'index',
        name: '支付项管理',
        component: () => import('@/views/channel/index'),
        meta: { title: '支付项管理', icon: 'channel' }
      }
    ]
  },
  // 活动
  // {
  //   path: '/activity',
  //   component: Layout,
  //   redirect: '/activity/index/',
  //   name: '活动管理',
  //   meta: { title: '活动管理', icon: 'activity' },
  //   children: [
  //     {
  //       path: 'index',
  //       name: '活动管理',
  //       component: () => import('@/views/activity/index'),
  //       meta: { title: '活动管理', icon: 'activity' }
  //     }
  //   ]
  // },
  // 报告管理路由
  {
    path: '/doc',
    component: Layout,
    redirect: '/doc/index/',
    name: '报告管理',
    meta: { title: '报告管理', icon: 'form' },
    children: [
      {
        path: 'index',
        name: '系统文件',
        component: () => import('@/views/report/index'),
        meta: { title: '系统文件', icon: 'system' }
      }
    ]
  },
  // 主题, 修改订阅表的数据结构
  {
    path: '/theme',
    component: Layout,
    redirect: '/theme/index/',
    name: '主题管理',
    meta: { title: '主题管理', icon: 'theme' },
    children: [
      {
        path: 'index',
        name: '主题管理',
        component: () => import('@/views/theme/index'),
        meta: { title: '主题管理', icon: 'theme' }
      }
    ]
  },
  // 活动, 后台新建活动(保存活动的二维码), 查看二维码
  // 系统设置, 数据统计, 系统开关(提审, 客服好, 日获取文件数)
  { path: '*', redirect: '/', hidden: true }
]

export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})

// 异步需要根据权限来加载的路由表
export const asyncRouterMap = [

]
